package model.parser
{
	import model.vo.AbstractPageItem;
	import model.vo.AbstractPageVO;
	
	import mx.collections.ArrayCollection;
	
	public class PageParser implements IPageParser
	{
		private var _pages:ArrayCollection;

		public function parse(data:*, count:int):void
		{
			var xml:XML = XML(data);
			var items:XMLList = xml.children();
			var vo:AbstractPageVO = AbstractPageVO(_pages.getItemAt(count-1));
			vo.title = xml..title;
			
			items = items[1].children();
			
			var l:int = items.length();
			var i:int = 0;
			var item:AbstractPageItem;
			for(; i < l; ++i)
			{
				item = new AbstractPageItem();
				item.url = items[i]..url;
				item.copy = items[i]..copy;
				vo.items.push(item);
			}
		}
		
		public function set pages(val:ArrayCollection):void
		{
			_pages = val;
		}
		
	}
}